<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自增自减</title>
</head>
<body>
    <button onclick="reduce()">-</button>
    <input onkeyup="check()"  id="mn" style="width: 40px" value="1" />
    <button onclick="add()">+</button>
    库存1个~10个
<script>
    function check() {
        console.log(11);
        if (parseInt(mn.value)>10){
            mn.value = 10;
        }
    }
    function reduce() {
        if(mn.value >1 ){
            mn.value = parseInt(mn.value)-1;
        }else {
            mn.value = parseInt(mn.value);
            }
    }
    function add() {
        console.log(1);
        if(mn.value<10) {
            mn.value=parseInt(mn.value)+1;
        }else{
            mn.value=10;
        }
    }
</script>
</body>
</html>